package com.codeoss.framework.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.codeoss.framework.response.WorkflowTaskManagementResponse;
import com.codeoss.framework.service.IWorkflowTaskManagementService;

@Controller
@RequestMapping("workflowtaskmanagement")
public class WorkflowTaskManagementController {
	@Autowired
	private IWorkflowTaskManagementService workflowTaskManagementService;
	
	@RequestMapping(value = "init", method = RequestMethod.GET)
	@ResponseBody
	public WorkflowTaskManagementResponse init(){
		WorkflowTaskManagementResponse workflowTaskManagementResponse=workflowTaskManagementService.init();
		return workflowTaskManagementResponse;
	}
	
	@RequestMapping(value = "approve", method = RequestMethod.POST)
	@ResponseBody
	public WorkflowTaskManagementResponse approve(@RequestParam("taskId") Long taskId,@RequestParam("opinion") String opinion){
		WorkflowTaskManagementResponse workflowTaskManagementResponse=workflowTaskManagementService.approve(taskId,opinion);
		return workflowTaskManagementResponse;
	}
	
	@RequestMapping(value = "reject", method = RequestMethod.POST)
	@ResponseBody
	public WorkflowTaskManagementResponse reject(@RequestParam("taskId") Long taskId,@RequestParam("opinion") String opinion){
		WorkflowTaskManagementResponse workflowTaskManagementResponse=workflowTaskManagementService.reject(taskId,opinion);
		return workflowTaskManagementResponse;
	}
	
	@RequestMapping(value = "back", method = RequestMethod.POST)
	@ResponseBody
	public WorkflowTaskManagementResponse back(@RequestParam("taskId") Long taskId,@RequestParam("opinion") String opinion){
		WorkflowTaskManagementResponse workflowTaskManagementResponse=workflowTaskManagementService.back(taskId,opinion);
		return workflowTaskManagementResponse;
	}
	
	@RequestMapping(value = "resubmit", method = RequestMethod.POST)
	@ResponseBody
	public WorkflowTaskManagementResponse resubmit(@RequestParam("taskId") Long taskId){
		WorkflowTaskManagementResponse workflowTaskManagementResponse=workflowTaskManagementService.resubmit(taskId);
		return workflowTaskManagementResponse;
	}
	
	@RequestMapping(value = "getCount", method = RequestMethod.GET)
	@ResponseBody
	public WorkflowTaskManagementResponse getCount(){
		WorkflowTaskManagementResponse workflowTaskManagementResponse=workflowTaskManagementService.getCount();
		return workflowTaskManagementResponse;
	}
	
	@RequestMapping(value = "onPageChangeHandler", method = RequestMethod.GET)
	@ResponseBody
	public WorkflowTaskManagementResponse onPageChangeHandler(@RequestParam("pageType") String pageType){
		WorkflowTaskManagementResponse workflowTaskManagementResponse=workflowTaskManagementService.onPageChangeHandler(pageType);
		return workflowTaskManagementResponse;
	}
	
	@RequestMapping(value = "onPageHandler", method = RequestMethod.GET)
	@ResponseBody
	public WorkflowTaskManagementResponse onPageHandler(@RequestParam("pageType") String pageType,@RequestParam("page") Integer page){
		WorkflowTaskManagementResponse workflowTaskManagementResponse=workflowTaskManagementService.onPageHandler(pageType,page);
		return workflowTaskManagementResponse;
	}
}
